package cn.bgs.service.impl;

import cn.bgs.common.R;
import cn.bgs.pojo.CommentEvaluation;
import cn.bgs.mapper.CommentEvaluationMapper;
import cn.bgs.service.CommentEvaluationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 留言评价表 服务实现类
 * </p>
 *
 * @author Mr.Zhao
 * @since 2022-08-08
 */
@Service
public class CommentEvaluationServiceImpl extends ServiceImpl<CommentEvaluationMapper, CommentEvaluation> implements CommentEvaluationService {

    @Autowired
    private CommentEvaluationMapper commentEvaluationMapper;

    @Override
    public R findCommentEvaluation(String comEvaTitle,String comEvaFrom) {

        List<CommentEvaluation> commentEvaluationList = commentEvaluationMapper.findCommentEvaluation(comEvaTitle, comEvaFrom);

        return R.ok().data("commentEvaluationList",commentEvaluationList);
    }

    @Override
    public R findCommentEvaluationId(Integer id) {

        CommentEvaluation commentEvaluation = commentEvaluationMapper.findCommentEvaluationId(id);

        return R.ok().data("commentEvaluation",commentEvaluation);
    }

    @Override
    public R delfindCommentEvaluation(Integer id) {

        Integer i = commentEvaluationMapper.delCommentEvaluation(id);

        if (i!=0){
            return R.ok();
        }else {
            return R.error().data("error","删除失败");
        }
    }
}
